import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/pages/nft_pages/home_pages/my_collection_list/my_collection_list_page.dart';
import 'package:yysk_app/pages/nft_pages/my_blind/my_blind_list_page.dart';
import 'package:yysk_app/pages/nft_pages/my_prop/prop_list_page.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/widget/lazy_network_image.dart';

class MyCollectionItemWidget extends StatelessWidget {
  final dynamic item;
  final dynamic type;
  const MyCollectionItemWidget({super.key, required this.item, this.type});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (type == 'Collection') {
          Get.toNamed(
            '${MyCollectionListPage.path}?id=${item.collectionId}',
            arguments: {'id': item.collectionId},
          );
        } else if (type == 'blindbox') {
          Get.toNamed(
            '${MyBlindListPage.path}?boxId=${item.boxId}&boxName=${item.boxName}',
            arguments: {'boxId': item.boxId, 'boxName': item.boxName},
          );
        } else {
          Get.toNamed(
            '${MyPropListPage.path}?propId=${item.propId}&propName=${item.title}',
            arguments: {'propId': item.propId, 'propName': item.title},
          );
        }
      },
      child: Container(
        width: context.width,
        margin: const EdgeInsets.only(bottom: 12),
        clipBehavior: Clip.antiAlias,
        decoration: BoxDecoration(
          color: AppColors.backgroundColorGrey2,
          borderRadius: BorderRadius.circular(10.px),
          boxShadow: [
            BoxShadow(
              color: AppColors.backgroundColorBlack.withAlpha(25),
              offset: const Offset(0, 14),
              blurRadius: 24,
              spreadRadius: 0,
            ),
          ],
        ),
        child: Stack(
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.start,
              // crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                LazyImage(
                  imageUrl:
                      type == 'Collection'
                          ? '${item.coverImageUrl}'
                          : (type == 'blindbox'
                              ? '${item.boxCoverImageUrl}'
                              : '${item.propImageUrl}'),
                  width: context.width,
                  boxFit: BoxFit.cover,
                  height: 166.px,
                  alignment: Alignment.topCenter,
                  borderRadius: 0,
                ),
                Padding(
                  padding: EdgeInsets.fromLTRB(6.px, 8.px, 6.px, 0),
                  child: SizedBox(
                    width: context.width,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(height: 8.px),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            SizedBox(
                              width: 90.px,
                              child: Text(
                                '${type == 'Collection' ? item.collectionName : (type == 'blindbox' ? item.boxName : item.title)}',
                                style: TextStyle(
                                  height: 1,
                                  color: AppColors.fontColor,
                                  fontSize: 13.px,
                                ),
                                textAlign: TextAlign.left,
                                overflow: TextOverflow.ellipsis,
                              ),
                            ),
                            Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Container(
                                  padding: EdgeInsets.fromLTRB(
                                    6.px,
                                    0.px,
                                    6.px,
                                    0.px,
                                  ),
                                  decoration: BoxDecoration(
                                    color: Colors.transparent,
                                    borderRadius: BorderRadius.circular(4.px),
                                  ),
                                  child: Center(
                                    child: Text(
                                      '持有${type == 'Collection' ? item.productCount : (type == 'blindbox' ? item.holdCount : item.count)}',
                                      style: TextStyle(
                                        color: AppColors.backgroundColorGrey,
                                        fontSize: 13.px,
                                      ),
                                      textAlign: TextAlign.center,
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
            // if(item?.collectionEquity=='DIGITAL_IDENTITY') Positioned(
            //   top: 6.px,
            //   right: 6.px,
            //   child: Container(
            //     padding: EdgeInsets.only(
            //       left: 4.px,
            //       right: 4.px,
            //       top: 0.px,
            //       bottom: 0.px,
            //     ),
            //     decoration: BoxDecoration(
            //       gradient: LinearGradient(
            //         colors: [
            //           AppColors.startColor,
            //           AppColors.endColor,
            //         ], // 定义渐变颜色
            //         begin: Alignment.centerLeft,
            //         end: Alignment.centerRight,
            //       ),
            //       borderRadius: BorderRadius.circular(4.px),
            //     ),
            //     // width: 48.px,
            //     // height: 16.px,
            //     child: Center(
            //       child: Text(
            //         '数字身份',
            //         style: TextStyle(
            //           fontSize: 12.px,
            //           color: AppColors.fontColorBlack,
            //         ),
            //       ),
            //     ),
            //   ),
            // ),
           Positioned(
              top: 6.px,
              right: 6.px,
              child: Container(
                padding: EdgeInsets.only(
                  left: 4.px,
                  right: 4.px,
                  top: 0.px,
                  bottom: 0.px,
                ),
                decoration: BoxDecoration(
                  color: Color.fromRGBO(0, 255, 173, 1),
                  borderRadius: BorderRadius.circular(4.px),
                ),
                // width: 48.px,
                // height: 16.px,
                child: Center(
                  child: Text(
                    '${item.collectionEquity}',
                    style: TextStyle(
                      fontSize: 12.px,
                      color: AppColors.fontColorBlack,
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
